package com.atguigu.gulimall.product.controller;


import com.atguigu.common.utils.R;
import com.atguigu.gulimall.product.entity.Member;
import com.atguigu.gulimall.product.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/product/member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    /**
     *
     */
    @PostMapping("/save")
    public R saveMember(@RequestBody Member member){
        memberService.saveMember(member);
        return R.ok();
    }

    /**
     *
     */
    @PostMapping("/updateMember")
    public R updateMember(@RequestBody Member member){
        memberService.updateMember(member);
        return R.ok();
    }

    @PostMapping("/findPage")
    public List<Member> findPage() {
        return memberService.findPage(null, null, null);
    }


    @PostMapping("/deleteMember")
    public R deleteMember(@RequestBody List<Long> ids) {
        memberService.deleteMember(ids);
        return R.ok();
    }

    @PostMapping("/findById")
    public Member findById(@RequestParam("id") Long id) {

        return memberService.findById(id);
    }
}
